package com.itheima.Jiuye08;

public class Employee implements Comparable<Employee>{
    private String name;
    private int age;
    private int salary;

    public Employee() {
    }

    public Employee(String name, int age, int salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }
   // 按照工资从高到底排序输出结果
   // (工资相同，按照年龄从低到高，工资和年龄都相同，
//      按照姓名字典顺序排列)
    @Override
    public int compareTo(Employee o) {
        int a = this.salary - o.salary;
         a = a==0? this.age - o.age :a;
         a = a==0?this.name.compareTo(o.name):a;

        return a;
    }
}
